﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WPFDevelopers.Minimal.Helpers;

namespace Client.View
{
    /// <summary>
    /// SkinView.xaml 的交互逻辑
    /// </summary>
    public partial class SkinView : UserControl
    {
        public SkinView()
        {
            InitializeComponent();
            FlowDocument flowDocument = new FlowDocument();

            // 创建段落
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(new Run("Welcome to WPF FlowDocument!"));

            // 创建表格
            Table table = new Table();
            table.Columns.Add(new TableColumn());
            table.Columns.Add(new TableColumn());

            TableRowGroup rowGroup = new TableRowGroup();
            TableRow row = new TableRow();
            row.Cells.Add(new TableCell(new Paragraph(new Run("Cell 1"))));
            row.Cells.Add(new TableCell(new Paragraph(new Run("Cell 2"))));
            rowGroup.Rows.Add(row);

            table.RowGroups.Add(rowGroup);

            // 创建列表
            List list = new List();
            list.ListItems.Add(new ListItem(new Paragraph(new Run("Item 1"))));
            list.ListItems.Add(new ListItem(new Paragraph(new Run("Item 2"))));

            // 将块添加到 FlowDocument
            flowDocument.Blocks.Add(paragraph);
            flowDocument.Blocks.Add(table);
            flowDocument.Blocks.Add(list);

            // 将 FlowDocument 分配给 RichTextBox
            richTextBox.Document = flowDocument;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Application.Current.Resources.MergedDictionaries[0].Source = 
            //ResourceDictionary resourceDictionary = new ResourceDictionary();
            //resourceDictionary.Source= new Uri(@"D:\Desktop\智能制造\招标运维工具\Tender.Tool\Client\ResourceDictionary\ColorsViolet.xaml");
            //var data = Application.Current.Resources.MergedDictionaries[0];
            //Application.Current.Resources.MergedDictionaries.Remove(data);
            //Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
            var lightDark = sender as ToggleButton;
            if (lightDark == null) return;
            ControlHelper.ToggleLightAndDark(lightDark.IsChecked == true);
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            PrintDialog printDialog = new PrintDialog();
            if (printDialog.ShowDialog() == true)
            {
                // 获取要打印的内容，这里以窗口的内容为例
                var visual = this.Content as Visual;

                // 打印
                printDialog.PrintVisual(visual, "Printing Main Window");
            }
        }
    }
}
